package com.daxue.commons.logging;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

/**
 * @author daxue0929
 * @date 2023/3/10
 */

@Data(staticConstructor = "newInstance")
@Accessors(chain = true)
public class Event {
    private String id;
    private String eventType;
    private boolean success = true;
    private Object content;
    private Map<String, String> keywords;




    public Event addKeyword(String keyword, String value) {
        Optional.ofNullable(keywords)
            .orElseGet(() -> keywords = new HashMap<>())
            .put(keyword, value);
        return this;
    }

}
